﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lion
{
    public class AccountClass : ICachedCollection<short, AccountClass>
    {
        public virtual short ID { get; set; }
        public virtual string Name { get; set; }

        private static Dictionary<short, AccountClass> _All;
        public static Dictionary<short, AccountClass> All
        {
            get
            {
                if (null == _All)
                {
                    _All = ObjectAssembler.GetAllObjects<AccountClass>()
                                        .ToDictionary(c => c.ID, c => c);
                }
                return _All;
            }
            set { _All = value; }

        }


        public void AddToCache(short ID, AccountClass Value)
        {
            _All[ID] = Value;
        }

        public bool RemoveFromCache(short ID)
        {
            return _All.Remove(ID);
        }

        public void ClearCollection()
        {
            _All = null;
        }
    }
}
